class MinStack {
public:
    stack<int> st;          //一个栈正常进出
    stack<int> minstack;    //一个栈，栈顶就是最小值
    MinStack() {
        
    }
    //入栈
    void push(int val) {
        st.push(val);
        //如果最小栈为空，或者元素小于当前最小（最小栈栈顶）
        if(minstack.empty()||minstack.top()>=val)
        {
            minstack.push(val);
        }
    }
    
    void pop() {
        if(st.top()==minstack.top())
        {
            minstack.pop();
        }
        st.pop();   //正常的栈出就行
        
    }
    
    int top() {
        return st.top();
    }
    
    int getMin() {
        return minstack.top();
    }
};

/**
 * Your MinStack object will be instantiated and called as such:
 * MinStack* obj = new MinStack();
 * obj->push(val);
 * obj->pop();
 * int param_3 = obj->top();
 * int param_4 = obj->getMin();
 */